package MR_process;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;

public class Bean3 implements WritableComparable<Bean3>{
    private String word,id;
    private long count,len,distinct_id;
    @Override
    public String toString() {
        return word + "\t"+ id +"\t"+ count+"\t"+len+"\t"+distinct_id;
    }
    @Override
    public void write(DataOutput out) throws IOException {
        //注意数据类型
        out.writeUTF(word);
        out.writeUTF(id);
        out.writeLong(count);
        out.writeLong(len);
        out.writeLong(distinct_id);
    }
    @Override
    public void readFields(DataInput in) throws IOException {
        //注意和write的顺序保持对应一致
        this.word=in.readUTF();
        this.id=in.readUTF();
        this.count=in.readLong();
        this.len=in.readLong();
        this.distinct_id=in.readLong();
    }
    @Override
    public int compareTo(Bean3 o) {
        int q=word.compareTo(o.getWord());
        if(q==0) return 0;
        else if(q<0) return -1;
        return 1;
    }
    public Bean3(){}
    public Bean3(String word, String id, long count, long len, long distinct_id) {
        this.word = word;
        this.id = id;
        this.count = count;
        this.len = len;
        this.distinct_id = distinct_id;
    }
    public String getWord() {
        return word;
    }
    public void setWord(String word) {
        this.word = word;
    }
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public long getCount() {
        return count;
    }
    public void setCount(long count) {
        this.count = count;
    }
    public long getLen() {
        return len;
    }
    public void setLen(long len) {
        this.len = len;
    }
    public long getDistinct_id() {
        return distinct_id;
    }
    public void setDistinct_id(long distinct_id) {
        this.distinct_id = distinct_id;
    }
}
